package com.example.back.common;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
//@EnableConfigurationProperties( DeepseekFactory.class)
@ConditionalOnClass( DeepseekFactory.class)
@Slf4j
public class DeepseekFactory {

    @Autowired
    private DeepSeekConfig deepSeekConfig;

    @Bean("deepSeekClient")
    @ConditionalOnMissingBean(name = "deepSeekClient")
    public DeepSeekClient deepSeekClient() {
        log.info("deepSeekClient 创建成功");
        return DeepSeekClient.builder()
                .apiKey(deepSeekConfig.getApiKey())
                .restTemplate(new RestTemplate())
                .build();
    }
}
